$(function() {
	

	 $.ajax({
        url: severUrl+'index.php?m=Web&a=getStock',
        type: 'GET',
        dataType: 'JSONP'
    })
    .done(function(data) {
        console.log("success");
        console.log(data);
        $('#STOCK_word').find('.p3').text(data.time);
        $('#STOCK_word').find('.p2').text('HK＄'+data.g_price);
        $('#STOCK_word').find('.p4').text(isIfFun(data.isUp)+data.stock1+' | '+isIfFun(data.isUp)+data.stock2);
        function isIfFun(data){
            if (data > 0) {
                return '+ ';
            }else if (data < 0){
                return '- ';
            }else if(data == 0){
                return ' ';
            }
        }
    })
    .fail(function() {
        console.log("error");
    });


    $.ajax({
        url: severUrl+'index.php?m=Web&a=investors',
        type: 'GET',
        dataType: 'JSONP'
    })
    .done(function(data) {

        console.log("success");
        console.log(data);

      	investor_newsFun(data.investor_news);
      	financial_informationFun(data.financial_information);
     	publicationsFun(data.publications);
        
    })
    .fail(function() {
        console.log("error");
    })
    .always(function() {
        console.log("complete");
    });




	// investor_news
	function investor_newsFun(data){
	    var investorList = $('#investorList');
	    var html = '';

	    for (var i = 0; i < data.length; i++) {
			 html +='<li><a href="article.html?article_id='+data[i].article_id+'"  class="clearfloat"> <div class="imgC"><img src="'+data[i].image_url+'"></div> <div class="word"><div class="head">'+data[i].title+'</div><div class="info">'+data[i].seo_description+'</div></div></a></li>'
	    }
	    investorList.html(html);
	}
	// investor_news END


	function financial_informationFun(data){
	    var FinancialLsCn = $('#FinancialLsCn');
	    var icon = ['&#xe644;','&#xe644;'];
	    var html = '';


	    for (var i = 0; i < data.length; i++) {
	    	html +='<div class="swiper-slide"><div class="indo"><div class="infoC"><div class="head">'+data[i].title+'</div><div class="iconC"><i class="iconfont">'+icon[i]+'</i></div><p>'+data[i].describe+'</p></div></div><div class="download"><a href="'+data[i].image_url+'">download</a></div></div>';
	    }
	    FinancialLsCn.html(html);

	    function FinancialInformationSwiper(){
	    	var FinancialInformationSwiper = new Swiper ('.FinancialInformationSwiper', {
		        direction : 'horizontal',
		        slidesPerView : 'auto'
		    })  
	    }

	    FinancialInformationSwiper();

	  
	}

	// investor_news end


	// publications
	function publicationsFun(data){
	     var PublicationslsCn = $('#PublicationslsCn');
	    var icon = ['&#xe640;','&#xe640;','&#xe640;','&#xe640;'];
	    var html = '';

	    for (var i = 0; i < data.length; i++) {
	    	 html += '<div class="swiper-slide"><a href="'+data[i].image_url+'"><div class="head">'+data[i].title+'</div><div class="iconC"><i class="iconfont">'+icon[i]+'</i></div><p>'+data[i].describe+'</p></a></div>'
	    }

	    PublicationslsCn.html(html);
	     function DOWNLOADlist(){
		       var DOWNLOADlist = new Swiper ('.swiper-DOWNLOADlist', {
		        loop: true,

		    })  
		   }

		   DOWNLOADlist();
	}
	// publications end


})